<?php 
session_start(); 
$user = $_SESSION['user'];
if (empty($user)) {
	header("location:login.php");
}
date_default_timezone_set('Asia/Shanghai');
if (isset($user['valid_to']) && $user['valid_to']) {
    $left_days = round((strtotime($user['valid_to']) - time()) / 86400);
}
?>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style>
html {
    height: 100px;
    padding: 0;
    margin: 0;
}
body {
    height: 100px;
    overflow: hidden;
    margin: 0px;
    padding: 0px;
    background: white;
}
ul {
    padding: 0;
    margin: 0;
}

li:first-child {
  margin-top: 0px;
}

li {
  cursor: pointer;
  text-align: center;
  padding: 1px 3px;
  font-family: sans-serif;
  font-size: 0.8em;
  /* width: 80px; */
  margin-top: 1px;
  background: #cccccc;
  list-style: none;
}
li:hover {
  background: #aaaaaa;
}

</style>
<script language="javascript">

function click(color) {
  switch(color.id) {
	case "function1":
		chrome.tabs.executeScript(null, {code:"retrieve(0, 50);"});
		break;
	case "function2":
		chrome.tabs.executeScript(null,
        {code:"retrieve(50, 100);"});
		break;
	case "function3":
		chrome.tabs.executeScript(null,
        {code:"retrieve(100, 150);"});
		break;
	case "function4":
		chrome.tabs.executeScript(null,
        {code:"retrieve(150, 200);"});
		break;
	case "function5":
		chrome.tabs.executeScript(null,
        {code:"retrieve();"});
		break;
	case "function7":
		chrome.tabs.executeScript(null,
        {code:"page_retrieve();"});
		break;

	case "function6":
		chrome.tabs.executeScript(null,
        {code:"retrieve_category();"});
		break;
	case "function8":
		var arg = color.title;
		switch(arg){
			case "1":
				chrome.tabs.executeScript(null,
			        {code:"retrieve_keywords(1);"});
				break;
			case "2":
				chrome.tabs.executeScript(null,
			        {code:"retrieve_keywords(2);"});
				break;
			case "3":
				chrome.tabs.executeScript(null,
			        {code:"retrieve_keywords(3);"});
				break;
			case "4":
				chrome.tabs.executeScript(null,
			        {code:"retrieve_keywords(4);"});
				break;
			default:
				chrome.tabs.executeScript(null,
			        {code:"retrieve_keywords();"});
				break;
							
		}
		break;

	case "function9":
		var arg = color.title;
		switch(arg){
			case "1":
				chrome.tabs.executeScript(null,
			        {code:"copy_words();"});
				break;
			case "2":
				chrome.tabs.executeScript(null,
			        {code:"copy_table();"});
				break;
			case "3":
				chrome.tabs.executeScript(null,
			        {code:"cube_gets();"});
				break;
			case "4":
				chrome.tabs.executeScript(null,
			        {code:"seo();"});
				break;
			default:
				break;
							
		}
		break;
	default:
		alert("you should choose one function.\n");
  }
  
  window.close();
}
</script>

<div style="width:200px;">
<span><?php echo $user['loginname'];?>
<?php 
if (isset($left_days)) {
    echo '(帐户到期还有'.$left_days.'天)';
}
?>
</span>
</div>
<ul>
    <li onclick="click(this)" id="function1">1-50</li>
    <li onclick="click(this)" id="function2">51-100</li>
    <li onclick="click(this)" id="function3">101-150</li>
    <li onclick="click(this)" id="function4">151-200</li>
    <li onclick="click(this)" id="function5">全部</li>
    <li onclick="click(this)" id="function7">页面全部</li>
    <li onclick="click(this)" id="function6">获取宝贝类目</li>

<?php
$str=<<<EOT
    <li>
    <span onclick="click(this)" id="function8">获取关键词</span>
 	<span onclick="click(this)" id="function8" title="1">[1]</span>
 	<span onclick="click(this)" id="function8" title="2">[2]</span>
 	<span onclick="click(this)" id="function8" title="3">[3]</span>
 	<span onclick="click(this)" id="function8" title="4">[4]</span>
    </li>
    <li onclick="click(this)" id="function9">
 	    <span onclick="click(this)" id="function9" title="1">复制词&nbsp;</span>
     	<span onclick="click(this)" id="function9" title="2">复制表</span>
     	<span onclick="click(this)" id="function9" title="3">词</span>
     	<span onclick="click(this)" id="function9" title="4">seo</span>
    </li>

EOT;

$username= $_SESSION['user']['taobaouser'];

if ($username == 'keyword'){
	echo $str;
}else {
}
?>
</ul>

